package com.hyt.it.ogt.kq.service.gov.feign.kh;

import com.hyt.common.apiInfor.ApiResponse;
import com.hyt.exception.exception.BusinessLogicException;
import com.hyt.it.ogt.kq.service.gov.feign.kh.model.AnalysisCenterFileParam;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;


/**
 * 评卷接口
 *
 * @author 刘恒活
 * @since 2020/9/27
 */
@Component
@Slf4j
public class KhClientHystrix implements FallbackFactory<KhClient> {


    @Override
    public KhClient create(Throwable cause) {
        log.error("考后接口调用失败.进入熔断", cause);
        return new KhClient() {
            @Override
            public ApiResponse<String> analysisCenterFile(AnalysisCenterFileParam param) {
                log.error("解析汇总文件远程接口调用失败.进入熔断");
                throw new BusinessLogicException(31433103, "解析汇总文件远程接口调用失败");
            }

            @Override
            public ApiResponse<Boolean> deleteAnalysisData(String timeId) {
                log.error("删除汇总文件远程接口调用失败.进入熔断");
                throw new BusinessLogicException(31433102, "删除汇总文件远程接口调用失败");
            }
        };
    }
}
